//
//  SoundController.m
//  MathMasterMain
//
//  Created by Jimmy Hahm on 10-04-05.
//  Copyright 2010 __MyCompanyName__. All rights reserved.
//

#import "SoundController.h"

@implementation SoundController

//sets up the sound controller
-(void) initSoundController{
	sounds = [[NSMutableArray alloc] init];
}

//adds a sound
-(void) addSound:(NSString*)name filetype:(NSString*)type{
	//Get the filename of the sound file:
	NSString *path = [[NSBundle mainBundle] pathForResource:name ofType:type];	
	AVAudioPlayer *sound = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:path] error:NULL];
	[sounds addObject:sound];
	[sound release];
	
	
}
//plays a sound at index soundNum
-(void) playSound:(int)soundNum{
	[[sounds objectAtIndex:soundNum] stop];
	[[sounds objectAtIndex:soundNum] play];
	
}
//sets the music
-(void) setMusic:(NSString*)name filetype:(NSString*)type{
	//Get the filename of the sound file:
	NSString *path = [[NSBundle mainBundle] pathForResource:name ofType:type];	
	music = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:path] error:NULL];
	music.numberOfLoops=-1;
	music.volume=0.5;
}
//plays the set music
-(void) playMusic{
	[music play];
}
//pauses the music
-(void) pauseMusic{
	[music pause];
}
//resets the music
-(void) resetMusic{
	[music stop];
}
-(void) dealloc{
	[music release];
	[sounds release];
	[super dealloc];
}


@end
